package com.gitee.swsk33.nuistcanteenselector.api;

import com.gitee.swsk33.nuistcanteenselector.dataobject.Canteen;
import com.gitee.swsk33.nuistcanteenselector.model.Result;
import com.gitee.swsk33.nuistcanteenselector.service.CanteenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
public class CanteenAPI {

	@Autowired
	private CanteenService canteenService;

	@GetMapping("/getcanteenbytype/{type}")
	public Result<Set<Canteen>> getByType(@PathVariable("type") String type) {
		return canteenService.getByType(type);
	}

	@GetMapping("/getcanteenbytypeandprice/{type}/{min}/{max}")
	public Result<Set<Canteen>> getByTypeAndPrice(@PathVariable("type") String type, @PathVariable("min") Integer min, @PathVariable("max") Integer max) {
		return canteenService.getByTypeAndPrice(type, min, max);
	}

	@GetMapping("/getcanteens")
	public Result<List<Canteen>> getAll() {
		return canteenService.getAll();
	}

}